<?php

namespace app\index\model;

use think\Db;
use think\Model;


class Qiu extends Model
{





    // 表名
    protected $name = 'qiu';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];










    public function buser()
    {
        return $this->belongsTo('Buser', 'id');
    }


    public  function yon()
    {
        Db::startTrans();
        try {


            $this->allowField(true)->save([


                'qiuname' => '三国演义',
                'jiage' => 33,

            ]);

            $this->buser()->save([

                'name' => 'guiqi',
                'age' => 21,
            ]);
            // 提交事务
            print_r('成功了');
            Db::commit();
        } catch (\Exception $e) {
            // 回滚事务
            print_r('失败了');
            Db::rollback();
        }
    }

}
